﻿@model FinalProject.Web.ViewModels.ClientViewModel

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)


    <fieldset>
        <legend>Client</legend>

        @Html.HiddenFor(model => model.Id)

        <div class="editor-label">
            @Html.LabelFor(model => model.PersonName.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PersonName.FirstName)
            @Html.ValidationMessageFor(model => model.PersonName.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PersonName.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PersonName.LastName)
            @Html.ValidationMessageFor(model => model.PersonName.LastName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PersonName.MiddleName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PersonName.MiddleName)
            @Html.ValidationMessageFor(model => model.PersonName.MiddleName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Phone)
            @Html.ValidationMessageFor(model => model.Phone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Stores)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.StoreId, Model.Stores.Select(option => new SelectListItem
           {
               Text = (option == null ? "None" : option.Name),
               Value = option.Id.ToString(),
               Selected = (Model != null) && (option.Id == Model.StoreId)
           }), "Choose...")
            @Html.ValidationMessageFor(model => model.Phone)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "List")
</div>
